package com.bit.talkoftoday;

import android.app.Activity;
import android.app.PendingIntent;
import android.content.Intent;
import android.graphics.Color;

import android.R.drawable;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.TimePicker;
import android.widget.TimePicker.OnTimeChangedListener;
import android.widget.Toast;
import android.widget.ToggleButton;

public class MainActivity_1 extends Activity implements OnClickListener,OnTimeChangedListener{

	private Button button_over1;
	private Button button_over2;
	private Button button_over3;
	private Button button_over4;
	private Button button_over5;
	private Button button_over6;
	private Button button_over7;
	public boolean[] yoil = new boolean[7];
	private int mHour,mMinute;
	private TimePicker timpicker;
	@Override

	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_main_activity_1);
		timpicker=(TimePicker)findViewById(R.id.datePicker1);
		timpicker.setOnTimeChangedListener(this);
		mHour=timpicker.getCurrentHour();
		mMinute=timpicker.getCurrentMinute();
		button_over1 = (Button)findViewById(R.id.Sun);
		button_over1.setOnClickListener(new View.OnClickListener(){
			public void onClick(View v){
				if(yoil[0]){
					yoil[0]=false;
					button_over1.setBackgroundColor(Color.WHITE);
				}
				else{
					yoil[0]=true;
					button_over1.setBackgroundResource(R.drawable.button_over1);
				}
			}
		});
		button_over2 = (Button)findViewById(R.id.Mon);
		button_over2.setOnClickListener(new View.OnClickListener(){
			public void onClick(View v){
				if(yoil[1]){
					yoil[1]=false;
					button_over2.setBackgroundColor(Color.WHITE);
				}
				else{
					yoil[1]=true;
					button_over2.setBackgroundResource(R.drawable.button_over2);
				}
			}
		});
		button_over3 = (Button)findViewById(R.id.Tue);
		button_over3.setOnClickListener(new View.OnClickListener(){
			public void onClick(View v){
				if(yoil[2]){
					yoil[2]=false;
					button_over3.setBackgroundColor(Color.WHITE);
				}
				else{
					yoil[2]=true;
					button_over3.setBackgroundResource(R.drawable.button_over3);
				}
			}
		});
		button_over4 = (Button)findViewById(R.id.Wed);
		button_over4.setOnClickListener(new View.OnClickListener(){
			public void onClick(View v){
				if(yoil[3]){
					yoil[3]=false;
					button_over4.setBackgroundColor(Color.WHITE);
				}
				else{
					yoil[3]=true;
					button_over4.setBackgroundResource(R.drawable.button_over4);
				}
			}
		});
		button_over5= (Button)findViewById(R.id.Thu);
		button_over5.setOnClickListener(new View.OnClickListener(){
			public void onClick(View v){
				if(yoil[4]){
					yoil[4]=false;
					button_over5.setBackgroundColor(Color.WHITE);
				}
				else{
					yoil[4]=true;	
					button_over5.setBackgroundResource(R.drawable.button_over5);
				}
			}
		});
		button_over6= (Button)findViewById(R.id.Fri);
		button_over6.setOnClickListener(new View.OnClickListener(){
			public void onClick(View v){
				if(yoil[5]){
					yoil[5]=false;
					button_over6.setBackgroundColor(Color.WHITE);
				}
				else{
					yoil[5]=true;
					button_over6.setBackgroundResource(R.drawable.button_over6);
				}
			}
		});
		button_over7= (Button)findViewById(R.id.Sat);
		button_over7.setOnClickListener(new View.OnClickListener(){
			public void onClick(View v){
				if(yoil[6]){
					yoil[6]=false;
					button_over7.setBackgroundColor(Color.WHITE);
				}
				else{
					yoil[6]=true;
					button_over7.setBackgroundResource(R.drawable.button_over7);
				}
			}
			
		});
		
		findViewById(R.id.btn_option_save).setOnClickListener(this);
		findViewById(R.id.btn_option_cancel).setOnClickListener(this);
	}

	@Override

	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.btn_option_save:
			Intent intent = new Intent();
			intent.putExtra("minute",mMinute);
			intent.putExtra("hour",mHour);
			intent.putExtra("week",yoil);
			setResult(RESULT_OK,intent);
			finish();
			break;
		case R.id.btn_option_cancel:
			setResult(RESULT_CANCELED);
			finish();
			break;
			
		}
	}

	@Override
	public void onTimeChanged(TimePicker arg0, int arg1, int arg2) {
		// TODO Auto-generated method stub
		mHour = arg1;
		mMinute = arg2;
	}
}